<?php

declare(strict_types=1);

namespace App\Model\Stat;

use Illuminate\Database\Eloquent\Model;

/**
 *  每日统计-话单详情
 */
class StatDailyCall extends Model
{
    protected $connection = 'stat';
    protected $table = 'stat_daily_call';

    const SUB_TYPE = [
        0 => '全部话单',
        1 => '常规',
        2 => '天天福利',
        3 => '天天福利（女用户呼叫）',
        4 => '随心聊',
        5 => '视频约会',
        6 => '特惠视频'
    ];

    static function getData($start = '', $callType = -1, $subType = -1)
    {
        $where = [
            ['flag', 1],
            ['call_subtype', 0]
        ];
        if ($start) $where[] = ['created_at', '>', $start];
        else $where[] = ['created_at', '>', date('Y-m-d')];

        $callType > -1 && $where[] = ['call_type', $callType];
        $subType > -1 && $where[] = ['call_subtype', $subType];
        return self::where($where)->get()->toArray();
    }
}
